/*
package com.demo.controller;

import com.demo.pojo.User;
import io.seata.core.context.RootContext;
import io.seata.core.exception.TransactionException;
import io.seata.tm.api.GlobalTransactionContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

*/
/**
 * @Author：万意佳
 * @Date:
 * @Description:
 **//*

@RestController
@RequestMapping("test")
@Slf4j
public class UserController {

    @Resource
//    UserService userService;

    @GetMapping("user")
    public  boolean add() throws TransactionException {

        User user1 = new User();
        user1.setName("张三");
        user1.setAge(10);

        User user2 = new User();

        User user3 = new User();
        user3.setName("李四");
        user3.setAge(20);

        List<User> list = new ArrayList<>();
        list.add(user1);
        list.add(user2);
        list.add(user3);

        try{
//            userService.saveBatch(list);
        }catch(Exception e){
            //事务手动回滚
            GlobalTransactionContext.reload(RootContext.getXID()).rollback();
            return false;
        }
        return true;
    }
}
*/
